package com.logic.saas.util;


import java.util.Properties;

import org.apache.commons.lang.StringUtils;

/**
 *  !禁止直接调用本类，所有去系统配置方法已经移入SysCahce 
 * @author jeffdong
 */
class SysConfig {
	public static final String CONFIG = "config.properties";
	private static Properties prop;

	static {
		prop = new Properties();
		try {
			prop.load(SysConfig.class.getClassLoader().getResourceAsStream(CONFIG));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static String getItem(String key) {
		 String result =prop.getProperty(key.toLowerCase(), "");
		 if(StringUtils.isEmpty(result)){
			 result =prop.getProperty(key, "");
		 }		 
		 return result; 
	}
	
	public static Integer getInteger(String key) {
		String value = SysConfig.getItem(key);
		Integer result = null;
		if (value != null && value.length() > 0) {
			result = Integer.parseInt(value);
		}
		return result;
	}
	
	public static Boolean getBoolean(String key) {
		String value = SysConfig.getItem(key);
		Boolean result = false;
		if (value != null && value.length() > 0) {
			if(value.trim().equals("true")){
				result = true;
			}
		}
		return result;
	}

}